#include <power.hpp>
#include <settings.hpp>

static Power* s_Power = nullptr;

Power* Power::Instance()
{
	if (s_Power == nullptr)
	{
		s_Power = new Power();
	}
	return s_Power;
}

Power::Power()
	: WorkQueue(PRIORITY_WQ_HIGH)
	, m_Pub("msg_power_s", sizeof(msg_power_s))
{
	memset(&m_Power, 0, sizeof(msg_power_s));
	m_Battery.Init();
}

Power::~Power()
{
}

void Power::RunImpl(void* arg)
{
	// 读取电池电压
	m_Battery.RunImpl(&m_Power);
	// 发布uORB传感器数据
	m_Pub.Publish(&m_Power, sizeof(msg_power_s));
	// LOGR("power %d %.2f\n", m_Power.adc, m_Power.vcc);
}